package cl.uchile.sketchpad.persistance.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import cl.uchile.sketchpad.persistance.model.SubjectVersionRegistration;

@Repository
public class SubjectVersionRegistrationDaoImpl implements SubjectVersionRegistrationDao {
	
	@PersistenceContext
	private EntityManager em;

	@Override
	@Transactional(readOnly = true)
	public List<SubjectVersionRegistration> getAll() {
		TypedQuery<SubjectVersionRegistration> q = em.createQuery("from SubjectVersionRegistration", SubjectVersionRegistration.class);
		return q.getResultList();
	}

	@Override
	public void persist(SubjectVersionRegistration subjectVersionRegistration) {
		em.persist(subjectVersionRegistration);
	}

	@Override
	public void remove(SubjectVersionRegistration subjectVersionRegistration) {
		em.remove(subjectVersionRegistration);
	}

}
